import { AdManager } from "../ads/AdManager";
import { BUNDLE_TYPE_ENUM, EVENT_NAME_ENUM, RELEASE_TYPE_ENUM } from "../base/EnumIndex";
import { AudioManager } from "../manager/AudioManager";
import { EventManager } from "../manager/EventManager";
import { GameManager } from "../manager/GameManager";
import { LevelManager } from "../manager/LevelManager";
import { UIManager } from "../manager/UIManager";

const { ccclass, property } = cc._decorator;

@ccclass
export class BackUI extends cc.Component {

    onLoad() {
        EventManager.ins.emit(EVENT_NAME_ENUM.PAUSE_TIME);
        AudioManager.stopAllAudio();
        AdManager.naoLiReportVideo(1, "跳过本关");
        if (AdManager.releaseType === RELEASE_TYPE_ENUM.oppo_mini || AdManager.releaseType === RELEASE_TYPE_ENUM.vivo_mini) {
            this.node.getChildByName("bg").getChildByName("qiuzhuhaoyou").active = false;
        }
    }

    clickBtnClose() {
        //继续
        let lvName = LevelManager.ins.getBundleName();
        if (lvName == "15_268") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_268")
            level15.resumeAni();
        }
        if (lvName == "15_271") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_271")
            level15.resumeAni();
        }
        if (lvName == "15_272") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_272")
            level15.resumeAni();
        }
        if (lvName == "15_279") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_279")
            level15.resumeAni();
        }
        if (lvName == "15_281") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_281")
            level15.resumeAni();
        }
        if (lvName == "15_287") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_287")
            level15.resumeAni();
        }
        if (lvName == "15_286") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_286")
            level15.resumeAni();
        }
        if (lvName == "15_288") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_288")
            level15.resumeAni();
        }
        if (lvName == "15_289") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_289")
            level15.resumeAni();
        }
        if (lvName == "15_299") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_299")
            level15.resumeAni();
        }
        if (lvName == "15_301") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_301")
            level15.resumeAni();
        }
        if (lvName == "15_302") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_302")
            level15.resumeAni();
        }
        if (lvName == "15_304") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_304")
            level15.resumeAni();
        }
        if (lvName == "15_305") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_305")
            level15.resumeAni();
        }
        if (lvName == "15_308") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_308")
            level15.resumeAni();
        }
        if (lvName == "15_307") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_307")
            level15.resumeAni();
        }
        if (lvName == "15_290") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_290")
            level15.resumeAni();
        }
        if (lvName == "15_309") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_309")
            level15.resumeAni();
        }
        if (lvName == "15_317") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_317")
            level15.resumeAni();
        }
        AudioManager.playClick();
        UIManager.ins.close();
        EventManager.ins.emit(EVENT_NAME_ENUM.RESUME_TIME);
    }
    /** 返回主页 */
    clickBtnHome() {
        AudioManager.playClick();
        UIManager.ins.closeAll();
        UIManager.ins.showUI("LevelUI", BUNDLE_TYPE_ENUM.HOME);
        AdManager.exitLv(LevelManager.ins.curLvInfo.name);
    }
    /** 跳过本关 */
    clickBtnPass() {
        AudioManager.playClick();
        GameManager.ins.passLevel();
    }

    /** 分享 */
    clickBtnShare() {
        AudioManager.playClick();
        AdManager.shareFriends();
    }
}